﻿<Window x:Class="MessageBoxWPF.MessageBox"
        x:Name="MessageBoxWindow"      
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:MessageBoxWPF" 
        xmlns:converter="clr-namespace:MessageBoxWPF.Converter" 
        mc:Ignorable="d" 
        MinWidth="300" 
        MaxWidth="500"
        WindowStartupLocation="CenterScreen" 
        AllowsTransparency="True" 
        WindowStyle="None"
        Title="{Binding Title}" 
        SizeToContent="WidthAndHeight" Background="White" >

    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Dictionary.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <converter:BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter" />
            <converter:SystemIconConverter x:Key="SystemIconConverter" />
            <local:MessageBoxVM x:Key="DesignViewModel" />
        </ResourceDictionary>
    </Window.Resources>

    <Border BorderBrush="{StaticResource DarkBorderBrush}" BorderThickness="2" d:DataContext="{StaticResource DesignViewModel}">
        <Grid Background="{StaticResource ContextMenuBackground}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition MaxHeight="165" />
                <RowDefinition Height="50" />
            </Grid.RowDefinitions>
            <TextBlock Foreground="White" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" FontSize="18" FontWeight="Bold"  Margin="15" Text="{Binding Title}" TextWrapping="Wrap" TextAlignment="Left" />
            <DockPanel Grid.Row="1" Margin="15,0,15,15" >
                <Image DockPanel.Dock="Left"
                Grid.Row="1"
                Grid.Column="0"
			    Source="{Binding Type, Converter={x:Static local:ImageConverterSingleton.Instance}}"
			    VerticalAlignment="Center"
			    HorizontalAlignment="Center"
			    Width="40"
			    Height="40"
			    Margin="0,0,15,0" />
                <ScrollViewer Grid.Row="1" Grid.Column="1" MaxHeight="150" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Padding="5">
                    <TextBox Style="{StaticResource BorderlessTextBox}" BorderThickness="0" Foreground="White" IsReadOnly="True"  
                             Text="{Binding Message}" TextWrapping="Wrap" MaxWidth="380" VerticalAlignment="Center"
                              />
                </ScrollViewer>
            </DockPanel>
            <DockPanel Grid.Row="2"  LastChildFill="False" HorizontalAlignment="Right" Margin="0,0,15,15">
                <Button Background="{StaticResource MenuColor}" Foreground="White" Margin="5,0,0,0" DockPanel.Dock="Right"
                    Visibility="{Binding CancelVisible, Converter={StaticResource BoolToVisibilityConverter}}"
                    Command="{Binding Cancel}"
                    CommandParameter="{Binding ElementName=MessageBoxWindow}">
                    <Label Foreground="White" Content="Cancel" Padding="0" Margin="5"/>
                </Button>
                <Button Background="{StaticResource MenuColor}" Foreground="White" Margin="5,0,0,0" DockPanel.Dock="Right"
                    Visibility="{Binding OkVisible, Converter={StaticResource BoolToVisibilityConverter}}"
                    Command="{Binding Ok}"
                    CommandParameter="{Binding ElementName=MessageBoxWindow}">
                    <Label Foreground="White" Content="Ok" Padding="0" Margin="5"/>
                </Button>
                <Button Background="{StaticResource MenuColor}" Foreground="White" Margin="5,0,0,0" DockPanel.Dock="Right"
                    Visibility="{Binding NoVisible, Converter={StaticResource BoolToVisibilityConverter}}"
                    Command="{Binding No}"
                    CommandParameter="{Binding ElementName=MessageBoxWindow}">
                    <Label Foreground="White" Content="No" Padding="0" Margin="5"/>
                </Button>
                <Button Background="{StaticResource MenuColor}" Foreground="White" Margin="5,0,0,0" DockPanel.Dock="Right" 
                    Visibility="{Binding YesVisible, Converter={StaticResource BoolToVisibilityConverter}}"
                    Command="{Binding Yes}"
                    CommandParameter="{Binding ElementName=MessageBoxWindow}">
                    <Label Foreground="White" Content="Yes" Padding="0" Margin="5" />
                </Button>
            </DockPanel>
        </Grid>
    </Border>
</Window>
